package com.yan.proxy;


import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyProxy implements InvocationHandler {

    private Object target;

    public MyProxy(Object target) {
             this.target=target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("方法执行前");
        Object obj = method.invoke(target, args);
        System.out.println("方法执行后");

        return obj;
    }
}
